package team.nmsg.ge.system.bean;

import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import team.nmsg.ge.system.interf.ISysBean;

import com.alibaba.fastjson.JSONObject;


@Entity
@Table( uniqueConstraints={@UniqueConstraint(columnNames={"roleName"})  }  )
public class SysRole implements ISysBean{

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer roleId;
	//角色名
	private String roleName;
	//描述
	private String roleRemark;
	
	private Long createTimestamp;
	
	//保留字段
	private String standby1;
	private String standby2;
	
	@ManyToMany(fetch=FetchType.LAZY  , mappedBy="roles")
	private Set<SysUser> users ;
    
	@ManyToMany(fetch=FetchType.LAZY  )
	@JoinTable(name="SYS_R_O",joinColumns=@JoinColumn(name="r_id"), inverseJoinColumns=@JoinColumn(name="o_id"))
	private Set<SysOper> opers ;
	
	public Integer getRoleId() {
		return roleId;
	}

	public void setRoleId(Integer roleId) {
		this.roleId = roleId;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public String getRoleRemark() {
		return roleRemark;
	}

	public void setRoleRemark(String roleRemark) {
		this.roleRemark = roleRemark;
	}

	public Long getCreateTimestamp() {
		return createTimestamp;
	}

	public void setCreateTimestamp(Long createTimestamp) {
		this.createTimestamp = createTimestamp;
	}

	public String getStandby1() {
		return standby1;
	}

	public void setStandby1(String standby1) {
		this.standby1 = standby1;
	}

	public String getStandby2() {
		return standby2;
	}

	public void setStandby2(String standby2) {
		this.standby2 = standby2;
	}

	public Set<SysUser> getUsers() {
		return users;
	}

	public void setUsers(Set<SysUser> users) {
		this.users = users;
	}

	public Set<SysOper> getOpers() {
		return opers;
	}

	public void setOpers(Set<SysOper> opers) {
		this.opers = opers;
	}

	@Override
	public JSONObject toJson() {
		JSONObject obj = new JSONObject();
		obj.put("roleId",roleId);
		obj.put("roleName",roleName);
		return obj;
	}

	
	
}
